Skip to content

Conversation

PhilArtin
Copy link

This won't affect most people in day-to-day usage, but this logic is incorrect. Without the parentheses around the ternary operator, EVERYTHING up to the "?" in the ternary operator will be evaluated as a single logic check. That is, "values.min >= this.props.minValue && values.max <= this.props.maxValue && this.props.allowSameValues" are all evaluated as the logic check of the ternary operator. This isn't the intent, I'm sure. I can cause this method to return true even when it shouldn't. For instance, change minValue to be minValue + 1 and maxValue to be maxValue - 1 and then move the slider to minValue on the track. It shouldn't work, but it does. Similarly, move the slider to maxValue on the track and it'll still work even though it shouldn't. Putting parentheses around the ternary expression fixes this and causes the proper behavior.

This won't affect most people in day-to-day usage, but this logic is incorrect. Without the parentheses around the ternary operator, EVERYTHING up to the "?" in the ternary operator will be evaluated as a single logic check. That is, "values.min >= this.props.minValue && values.max <= this.props.maxValue && this.props.allowSameValues" are all evaluated as the logic check of the ternary operator. This isn't the intent, I'm sure. I can cause this method to return true even when it shouldn't. For instance, change minValue to be minValue + 1 and maxValue to be maxValue - 1 and then move the slider to minValue on the track. It shouldn't work, but it does. Similarly, move the slider to maxValue on the track and it'll still work even though it shouldn't. Putting parentheses around the ternary expression fixes this and causes the proper behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant